while ((line = readline())) {
  if (line.includes('.')) {
    // ip -> number
    const arr = line.split('.')
    //         const temp = arr.reduce((p, c) => p.toString(2).padStart(8, '0') + c.toString(2).padStart(8, '0'))
    const temp = arr.map((v) => Number(v).toString(2).padStart(8, '0')).join('')
    console.log(parseInt(temp, 2))
  } else {
    // number -> ip
    const string = Number(line).toString(2).padStart(32, '0')
    //         let arr = []
    //         while(s = string.substring(0, 8)) {
    //             arr.push(s)
    //         }
    const arr = [
      string.slice(0, 8),
      string.slice(8, 16),
      string.slice(16, 24),
      string.slice(24, 32),
    ]
    const ip = arr.map((v) => parseInt(v, 2)).join('.')
    console.log(ip)
  }
}
